<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // let name;
        // const data = '这个人很懒什么也没留下';
        // console.log(name??data);


        // 如果name 是null 或者undefined 那么输出 data的值 
        // 否则输出 name的值 


        // const obj = {
        //     name:'张三',
        //     eat(){
        //         console.log(`${this.name}正在吃`);
        //     }
        // }

        // console.log(obj.name);
        // obj.eat()


        const user = {
            name:'大个',
            age:18,
            info:{
                city:'济南'
            },
            eat(){
                console.log(`${this.name}正在${this.info.city}吃把子肉`);
            }
        }

        console.log(user?.name);
        console.log(user?.height);// undefined

        user?.eat()
        user?.haha()// 报错  haha is not a function 
    


    </script>
</body>
</html>